需要启用 Windows Media Player 功能,否则会提示【System.Runtime.InteropServices.COMException:“没有注册类】操作步骤:控制面板>>程序>>启用或者关闭windows 功能>>选中 媒体功能>>Windows Media Player,点击确定即可
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Media;using System.Runtime.InteropServices;using System.IO;using TXTClass;namespace yinyue{ public partial class Form1 : Form { //txtclass // 416 593 42 16 //36 126 [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); public const int WM_SYSCOMMAND = 0x0112; public const int SC_MOVE = 0xF010; public const int HTCAPTION = 0x0002; int moshi = 1; public Form1() { InitializeComponent(); axWindowsMediaPlayer1.settings.setMode("loop", false);//循环播放 } string a = "1.mp3"; string im = ""; string[] Mname = new string[1000]; string[] duqu = new string[1000]; //初始化隐藏控件 void csyc() { label28.Visible = false; label29.Visible = false; label30.Visible = false; label74.Visible = false; label74.Location = new Point(0, 84); panel9.Visible = false; panel6.Visible = false; panel10.Visible = false; panel11.Visible = false; panel12.Visible = false; pictureBox15.Visible = false; panel14.Visible = false; panel16.Visible = false; panel20.Visible = false; panel20.Size = new Size(320, 200); panel20.Location = new Point(427, 51); } //******************************************* //****************皮肤图片******************* //******************************************* void images() { string wenjianBen = @"c:\yinyue\image"; if (!Directory.Exists(wenjianBen)) { return; } try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\image\imgs.txt")) { string img; //读取所有的内容 while ((img = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } im = img; if (im == "1") this.BackgroundImage = Properties.Resources._1; if (im == "2") this.BackgroundImage = Properties.Resources._2; if (im == "3") this.BackgroundImage = Properties.Resources._3; if (im == "4") this.BackgroundImage = Properties.Resources._4; if (im == "5") this.BackgroundImage = Properties.Resources._5; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } int yinliang = 35; //初始化音量 private void Form1_Load(object sender, EventArgs e) { //label79.Parent = this; axWindowsMediaPlayer1.Location = new Point(0, 0); axWindowsMediaPlayer1.Size = new Size(722, 224); panel21.Location = new Point(156, 49); panel21.Size = new Size(722, 169); images(); panel7.BackColor = System.Drawing.Color.FromArgb(100, 104, 104, 110); panel17.BackColor = System.Drawing.Color.FromArgb(220, 104, 104, 110); panel16.BackColor = System.Drawing.Color.FromArgb(40, 224, 224, 224); csyc(); //axWindowsMediaPlayer1.URL = a; this.axWindowsMediaPlayer1.settings.volume = yinliang;//初始化声音为35 label31.Text = ""; label14.Text = ""; label48.Text = ""; label49.Text = ""; label50.Text = ""; label51.Text = ""; label52.Text = ""; label53.Text = ""; label54.Text = ""; label55.Text = ""; label56.Text = ""; //this.BackgroundImage=Properties.Resources//初始化图片 } private void Form1_MouseDown(object sender, MouseEventArgs e) { //this.Cursor = System.Windows.Forms.Cursors.Hand; //改变鼠标样式 //ReleaseCapture(); //SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE HTCAPTION, 0); //this.Cursor = System.Windows.Forms.Cursors.Default; } private void timer1_Tick(object sender, EventArgs e) { timer2.Enabled = true; if (max == true) { //调用进度 jindu(); //时间进度 this.label4.Text = this.axWindowsMediaPlayer1.Ctlcontrols.currentPositionString; //歌曲时间长度 this.label13.Text = this.axWindowsMediaPlayer1.currentMedia.durationString; } else { jindujj(); this.label28.Text = this.axWindowsMediaPlayer1.Ctlcontrols.currentPositionString; //歌曲时间长度 this.label30.Text = this.axWindowsMediaPlayer1.currentMedia.durationString; } } private void label1_Click(object sender, EventArgs e) { this.Close(); } private void notifyIcon1_Click(object sender, EventArgs e) { if (this.Visible == true) { this.Hide(); this.ShowInTaskbar = true; } else { this.Visible = true; this.ShowInTaskbar = true; this.WindowState = FormWindowState.Normal; this.BringToFront(); } } private void label2_Click(object sender, EventArgs e) { this.Hide(); } //****************************************************** //***********************声音设置*********************** //****************************************************** int sy=35; void shengyin(int sy) { this.axWindowsMediaPlayer1.settings.volume = sy; } private void panel1_MouseDown(object sender, MouseEventArgs e) { if (laba == false) { laba = true; pictureBox2.Image = Properties.Resources.laba; } sy=e.Location.X; shengyin(sy); panel2.Size = new Size(sy, 4); //判断声音是否为零 if (sy == 0) { laba = false; pictureBox2.Image = Properties.Resources.labaguan; } } private void panel2_MouseDown(object sender, MouseEventArgs e) { sy = e.Location.X; shengyin(sy); panel2.Size = new Size(sy, 4); } //****************************************************** //***********************进度设置*********************** //****************************************************** double Tqsj;//全部时间 double Tdcj;//当前时间 double Tbfb;//百分比 double Tx; public void jindu() { Tdcj = this.axWindowsMediaPlayer1.Ctlcontrols.currentPosition; Tqsj = this.axWindowsMediaPlayer1.currentMedia.duration; Tbfb = Tdcj / Tqsj; Tx = 339 * Tbfb; panel4.Size = new Size((int)Tx, 4); if (Tx > 338 || Tx == 338) { #region 顺序 if (moshi == 1) { string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 if (MaxNum 1 >= zongshu) { MaxNum = -1; museic = Path.GetFileNameWithoutExtension(f2[0]); } else museic = Path.GetFileNameWithoutExtension(f2[MaxNum 1]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" museic ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; label31.Text = museic; label14.Text = museic; MaxNum = MaxNum 1; //timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } #endregion #region 单曲 if (moshi == 2) { string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[MaxNum]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" museic ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.settings.setMode("loop", true);//循环播放 //axWindowsMediaPlayer1.URL = bf; //timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } #endregion #region 随机 if (moshi == 3) { string museic; Random suiji = new Random(); int suiji1 = 0; suiji1 = suiji.Next(0, zongshu); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[suiji1]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" museic ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; label31.Text = museic; label14.Text = museic; //MaxNum = MaxNum 1; //timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } #endregion } } public void jindujj() { Tdcj = this.axWindowsMediaPlayer1.Ctlcontrols.currentPosition; Tqsj = this.axWindowsMediaPlayer1.currentMedia.duration; Tbfb = Tdcj / Tqsj; Tx = 339 * Tbfb; panel12.Size = new Size((int)Tx, 4); } //****************************************************** //***********************透明效果*********************** //****************************************************** //****************************************************** //***********************改变进度*********************** //****************************************************** //获取当前进度 double Alltime; double thisTime; int panleX; Double b; public void gaibian(double all, double thisp) { try { b = thisp / all; Alltime = this.axWindowsMediaPlayer1.currentMedia.duration; thisTime = Alltime * b; this.axWindowsMediaPlayer1.Ctlcontrols.currentPosition = thisTime; } catch (Exception) { // } } private void panel3_MouseDown(object sender, MouseEventArgs e) { panel4.Size = new Size(e.Location.X, 4); panleX = e.Location.X; gaibian(339, panleX); } private void panel4_MouseDown(object sender, MouseEventArgs e) { panel4.Size = new Size(e.Location.X, 4); panleX = e.Location.X; gaibian(339, panleX); } //添加歌曲 void tianjia() { string wenjianBen = @"c:\yinyue\lianjie"; if(xi==true) wenjianBen = @"c:\yinyue\lianjie\like"; if (!Directory.Exists(wenjianBen)) { Directory.CreateDirectory(wenjianBen); } StreamWriter sw = new StreamWriter(wenjianBen "\\" fileName[i] ".txt"); string img=a; sw.Write(img); sw.Close(); } //定义歌曲名数组 int i = 0; string[] fileName = new string[1000]; string[] luJing = new string[1000]; OpenFileDialog of = new OpenFileDialog(); void dakai() { of.InitialDirectory = "e:\\"; of.Filter = "mp3|*.mp3|wav|*.wav"; of.RestoreDirectory = true; of.FilterIndex = 1; of.Multiselect = true; of.ShowDialog(); a = of.FileName; FileInfo file = new FileInfo(a); fileName[i] = file.Name; } private void pictureBox5_Click(object sender, EventArgs e) { dakai(); //label14.Text = fileName[i]; //label31.Text = fileName[i]; tianjia(); if(ben==true) bendi(); //if(xi==true) //axWindowsMediaPlayer1.URL = a; //timer1.Enabled = true; } private void label5_MouseEnter(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = Properties.Resources.s; } private void label5_MouseLeave(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = null; } private void label6_MouseEnter(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = Properties.Resources.s; } private void label6_MouseLeave(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = null; } private void label7_MouseEnter(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = Properties.Resources.s; } private void label7_MouseLeave(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = null; } private void label8_MouseEnter(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = Properties.Resources.s; } private void label8_MouseLeave(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = null; } private void label9_MouseEnter(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = Properties.Resources.s; } private void label9_MouseLeave(object sender, EventArgs e) { Label lb = (Label)sender; lb.Image = null; } //定义喇叭开关 bool laba = true; private void pictureBox6_Click(object sender, EventArgs e) { if (laba == true) { laba = false; pictureBox6.Image = Properties.Resources.labaguan; //静音 this.axWindowsMediaPlayer1.settings.volume = 0; } else { laba = true; pictureBox6.Image = Properties.Resources.laba; this.axWindowsMediaPlayer1.settings.volume = sy; } } //开始或暂停 bool ks = true; private void pictureBox2_Click(object sender, EventArgs e) { if (ks == true) { ks = false; pictureBox2.Image = Properties.Resources.play_down; //暂停 axWindowsMediaPlayer1.Ctlcontrols.pause(); } else { ks = true; pictureBox2.Image = Properties.Resources.pause_down; //开始 axWindowsMediaPlayer1.Ctlcontrols.play(); } } //************************************************** //***************鼠标经过与离开图片的变化*********** //************************************************** #region 鼠标经过与离开图片的变化 private void pictureBox1_MouseEnter(object sender, EventArgs e) { pictureBox1.Image = Properties.Resources.preview_down; } private void pictureBox1_MouseLeave(object sender, EventArgs e) { pictureBox1.Image = Properties.Resources.preview_on; } private void pictureBox2_MouseEnter(object sender, EventArgs e) { if (ks == true) { pictureBox2.Image = Properties.Resources.pause_down; } else pictureBox2.Image = Properties.Resources.play_down; } private void pictureBox2_MouseLeave(object sender, EventArgs e) { if (ks == true) pictureBox2.Image = Properties.Resources.pause_on; else pictureBox2.Image = Properties.Resources.play_on; } private void pictureBox3_MouseEnter(object sender, EventArgs e) { pictureBox3.Image = Properties.Resources.next_down; } private void pictureBox3_MouseLeave(object sender, EventArgs e) { pictureBox3.Image = Properties.Resources.next_on; } private void pictureBox4_MouseEnter(object sender, EventArgs e) { pictureBox4.Image = Properties.Resources.hongxin; } private void pictureBox4_MouseLeave(object sender, EventArgs e) { pictureBox4.Image = Properties.Resources.favorite_on; } private void pictureBox5_MouseEnter(object sender, EventArgs e) { pictureBox5.Image = Properties.Resources.list_down; } private void pictureBox5_MouseLeave(object sender, EventArgs e) { pictureBox5.Image = Properties.Resources.list_on; } //鼠标离开控件 void likai(object sender) { Label lb = (Label)sender; lb.Image = null; } //鼠标接触控件 void jiechu(object sender) { Label lb = (Label)sender; lb.Image = Properties.Resources.s; } private void label19_MouseEnter(object sender, EventArgs e) { if (dianji19 == true) { } else jiechu(sender); } private void label19_MouseLeave(object sender, EventArgs e) { if (dianji19 == true) { } else likai(sender); } private void label18_MouseEnter(object sender, EventArgs e) { if (dianji18 == true) { } else jiechu(sender); } private void label18_MouseLeave(object sender, EventArgs e) { if (dianji18 == true) { } else likai(sender); } private void label22_MouseEnter(object sender, EventArgs e) { if (dianji22 == true) { } else jiechu(sender); } private void label22_MouseLeave(object sender, EventArgs e) { if (dianji22 == true) { } else likai(sender); } private void label20_MouseEnter(object sender, EventArgs e) { if (dianji20 == true) { } else jiechu(sender); } private void label20_MouseLeave(object sender, EventArgs e) { if (dianji20 == true) { } else likai(sender); } private void label21_MouseEnter(object sender, EventArgs e) { if (dianji21 == true) { } else jiechu(sender); } private void label21_MouseLeave(object sender, EventArgs e) { if (dianji21 == true) { } else likai(sender); } private void label24_MouseEnter(object sender, EventArgs e) { if (dianji24 == true) { } else jiechu(sender); } private void label24_MouseLeave(object sender, EventArgs e) { if (dianji24 == true) { } else likai(sender); } private void pictureBox1_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox1, "上一曲"); } private void pictureBox2_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox2, "开始/暂停"); } private void pictureBox3_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox3, "下一曲"); } private void pictureBox6_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox6, "音量"); } private void pictureBox4_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox4, "收藏"); } private void pictureBox5_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox5, "添加"); } private void pictureBox8_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox8, "换肤"); } private void pictureBox7_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox7, "设置"); } private void label2_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(label2, "最小化"); } private void pictureBox9_MouseHover(object sender, EventArgs e) { if (max == true) toolTip1.SetToolTip(pictureBox9, "精简模式"); else toolTip1.SetToolTip(pictureBox9, "普通模式"); } private void label1_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(label1, "关闭"); } private void pictureBox10_Click(object sender, EventArgs e) { } private void pictureBox10_MouseEnter(object sender, EventArgs e) { pictureBox10.Image = Properties.Resources.ss; } private void pictureBox10_MouseLeave(object sender, EventArgs e) { pictureBox10.Image = Properties.Resources.sousuo; } #endregion //**************************************************** //**********************窗口缩放********************** //**************************************************** //取消隐藏 void qxyc() { label28.Visible = true; label29.Visible = true; label30.Visible = true; panel9.Visible = true; panel10.Visible = true; panel11.Visible = true; panel12.Visible = true; pictureBox15.Visible = true; panel14.Visible = true; } //还原隐藏 void huanyuan() { this.Size = new System.Drawing.Size(877, 593); panel13.Location = new Point(771, 1); textBox1.Visible = true; panel7.Visible = true; pictureBox27.Visible = true; label31.Visible = true; button1.Visible = true; panel5.Visible = true; panel21.Visible = true; if (dianji19 == true) panel16.Visible = true; } void suofang() { if (max == true) { qxyc(); //部分隐藏及位置移动 max = false; pictureBox9.Image = Properties.Resources.jiantou1; this.Size = new Size(416, 593); //部分控件隐藏 panel7.Visible = false; panel5.Visible = false; textBox1.Visible = false; pictureBox27.Visible = false; button1.Visible = false; panel16.Visible = false; panel21.Visible = false; label31.Visible = false; label74.Visible = true; label79.Visible = false; if (pifu == true) { pifu = false; panel15.Visible = false; } //坐标改变 panel13.Location = new Point(310, 1); //转为精简界面 panel14.Size = new System.Drawing.Size(388, 57); panel11.Location = new Point(40, 120); label28.Location = new Point(40, 130); label30.Location = new Point(328, 130); panel14.Location = new Point(40, 160); panel9.Location = new Point(240, 240); pictureBox15.Location = new Point(210, 230); //pictureBox15.Location = new Point(300, 80); panel6.Visible = true; panel6.Location = new Point(13, 305); panel6.Size = new Size(388, 279); label74.Visible = true; label74.Text = label31.Text; //图片模式判定 播放类型 if (moshi == 1) pictureBox25.Image = Properties.Resources.shunxu; if (moshi == 2) pictureBox25.Image = Properties.Resources.danqu; if (moshi == 3) pictureBox25.Image = Properties.Resources.suiji; } else { label31.Visible = true; label74.Visible = false; label79.Visible = true; csyc(); huanyuan(); max = true; pictureBox9.Image = Properties.Resources.jiantou2; //图片模式判定 if (moshi == 1) pictureBox26.Image = Properties.Resources.shunxu; if (moshi == 2) pictureBox26.Image = Properties.Resources.danqu; if (moshi == 3) pictureBox26.Image = Properties.Resources.suiji; } } bool max = true; private void pictureBox9_Click(object sender, EventArgs e) { suofang(); bendi(); } private void label23_MouseHover(object sender, EventArgs e) { this.toolTip1.SetToolTip(label23, "创建列表"); } private void pictureBox15_Click(object sender, EventArgs e) { if (laba == true) { laba = false; pictureBox15.Image = Properties.Resources.labaguan; //静音 this.axWindowsMediaPlayer1.settings.volume = 0; } else { laba = true; pictureBox15.Image = Properties.Resources.laba; this.axWindowsMediaPlayer1.settings.volume = sy; } } private void panel9_MouseDown(object sender, MouseEventArgs e) { if (laba == false) { laba = true; pictureBox2.Image = Properties.Resources.laba; } sy = e.Location.X; shengyin(sy); panel10.Size = new Size(sy, 4); //判断声音是否为零 if (sy == 0) { laba = false; pictureBox10.Image = Properties.Resources.labaguan; } } private void panel10_MouseDown(object sender, MouseEventArgs e) { sy = e.Location.X; shengyin(sy); panel10.Size = new Size(sy, 4); } private void pictureBox18_MouseEnter(object sender, EventArgs e) { pictureBox18.Image = Properties.Resources.preview_down; } private void pictureBox18_MouseLeave(object sender, EventArgs e) { pictureBox18.Image = Properties.Resources.preview_on; } private void pictureBox16_MouseEnter(object sender, EventArgs e) { if (ks == true) { pictureBox16.Image = Properties.Resources.pause_down; } else pictureBox16.Image = Properties.Resources.play_down; } private void pictureBox16_MouseLeave(object sender, EventArgs e) { if (ks == true) pictureBox16.Image = Properties.Resources.pause_on; else pictureBox16.Image = Properties.Resources.play_on; } private void pictureBox17_MouseEnter(object sender, EventArgs e) { pictureBox17.Image = Properties.Resources.next_down; } private void pictureBox17_MouseLeave(object sender, EventArgs e) { pictureBox17.Image = Properties.Resources.next_on; } private void pictureBox14_MouseEnter(object sender, EventArgs e) { pictureBox14.Image = Properties.Resources.hongxin; } private void pictureBox14_MouseLeave(object sender, EventArgs e) { pictureBox14.Image = Properties.Resources.favorite_on; } private void pictureBox11_MouseEnter(object sender, EventArgs e) { pictureBox11.Image = Properties.Resources.list_down; } private void pictureBox11_MouseLeave(object sender, EventArgs e) { pictureBox11.Image = Properties.Resources.list_on; } private void pictureBox16_Click(object sender, EventArgs e) { if (ks == true) { ks = false; pictureBox16.Image = Properties.Resources.play_down; //暂停 axWindowsMediaPlayer1.Ctlcontrols.pause(); } else { ks = true; pictureBox16.Image = Properties.Resources.pause_down; //开始 axWindowsMediaPlayer1.Ctlcontrols.play(); } } private void pictureBox18_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox18, "上一曲"); } private void pictureBox16_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox16, "开始/暂停"); } private void pictureBox17_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox17, "下一曲"); } private void pictureBox14_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox14, "收藏"); } private void pictureBox11_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox11, "添加"); } private void pictureBox15_MouseHover(object sender, EventArgs e) { toolTip1.SetToolTip(pictureBox15, "音量"); } //*************************************** //******************皮肤设置************* //*************************************** bool pifu = false; private void pictureBox8_Click(object sender, EventArgs e) { if (panel20.Visible == true) panel20.Visible = false; if (pifu == false) { pifu = true; panel15.Visible = true; panel15.Size = new Size(357, 234); panel15.Location = new Point(355, 50); } else { pifu = false; panel15.Visible = false; } } private void pictureBox19_Click(object sender, EventArgs e) { this.BackgroundImage = Properties.Resources._1; //图片写入文件 string wenjian = @"c:\yinyue\image"; if (!Directory.Exists(wenjian)) { Directory.CreateDirectory(wenjian); } StreamWriter sw = new StreamWriter("c:\\yinyue\\image\\imgs.txt"); string img = "1"; sw.Write(img); sw.Close(); } private void pictureBox20_Click(object sender, EventArgs e) { this.BackgroundImage = Properties.Resources._2; //图片写入文件 string wenjian = @"c:\yinyue\image"; if (!Directory.Exists(wenjian)) { Directory.CreateDirectory(wenjian); } StreamWriter sw = new StreamWriter("c:\\yinyue\\image\\imgs.txt"); string img = "2"; sw.Write(img); sw.Close(); } private void pictureBox21_Click(object sender, EventArgs e) { this.BackgroundImage = Properties.Resources._3; //图片写入文件 string wenjian = @"c:\yinyue\image"; if (!Directory.Exists(wenjian)) { Directory.CreateDirectory(wenjian); } StreamWriter sw = new StreamWriter("c:\\yinyue\\image\\imgs.txt"); string img = "3"; sw.Write(img); sw.Close(); } private void Form1_Click(object sender, EventArgs e) { } private void pictureBox22_Click(object sender, EventArgs e) { this.BackgroundImage = Properties.Resources._4; //图片写入文件 string wenjian = @"c:\yinyue\image"; if (!Directory.Exists(wenjian)) { Directory.CreateDirectory(wenjian); } StreamWriter sw = new StreamWriter("c:\\yinyue\\image\\imgs.txt"); string img = "4"; sw.Write(img); sw.Close(); } private void pictureBox23_Click(object sender, EventArgs e) { this.BackgroundImage = Properties.Resources._5; //图片写入文件 string wenjian = @"c:\yinyue\image"; if (!Directory.Exists(wenjian)) { Directory.CreateDirectory(wenjian); } StreamWriter sw = new StreamWriter("c:\\yinyue\\image\\imgs.txt"); string img = "5"; sw.Write(img); sw.Close(); } private void pictureBox24_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.InitialDirectory = "c:\\"; of.Filter = "jpg|*.png|pmn|*"; of.RestoreDirectory = true; of.FilterIndex = 1; of.Multiselect = true; of.ShowDialog(); } private void panel8_MouseDown(object sender, MouseEventArgs e) { ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE HTCAPTION, 0); this.Cursor = System.Windows.Forms.Cursors.Default; } private void pictureBox25_MouseEnter(object sender, EventArgs e) { if (moshi == 1) pictureBox25.Image = Properties.Resources.shunxu2; if (moshi == 2) pictureBox25.Image = Properties.Resources.danqu2; if (moshi == 3) pictureBox25.Image = Properties.Resources.suiji2; } private void pictureBox25_MouseLeave(object sender, EventArgs e) { if (moshi == 1) pictureBox25.Image = Properties.Resources.shunxu; if (moshi == 2) pictureBox25.Image = Properties.Resources.danqu; if (moshi == 3) pictureBox25.Image = Properties.Resources.suiji; } private void pictureBox26_MouseEnter(object sender, EventArgs e) { if (moshi == 1) pictureBox26.Image = Properties.Resources.shunxu2; if (moshi == 2) pictureBox26.Image = Properties.Resources.danqu2; if (moshi == 3) pictureBox26.Image = Properties.Resources.suiji2; } private void pictureBox26_MouseLeave(object sender, EventArgs e) { if (moshi == 1) pictureBox26.Image = Properties.Resources.shunxu; if (moshi == 2) pictureBox26.Image = Properties.Resources.danqu; if (moshi == 3) pictureBox26.Image = Properties.Resources.suiji; } //*********************************************************** //************************导入本地歌曲*********************** //*********************************************************** string gequ = "c:\\yinyue\\lianjie"; int ye = 1; //页数 int MaxNum = 0; int zongshu = 0; string museic; //歌曲名字 void bendi() { MaxNum = 0; string[] files = Directory.GetFiles(gequ); zongshu = files.Length; ye = files.Length / 9;//几首歌曲 if (files.Length % 9 != 0) ye = ye 1; label70.Text = ye.ToString(); label100.Text = ye.ToString(); ye1 = 1; label58.Text = ye1.ToString(); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 while (true) { if (zongshu == 0) break; museic = Path.GetFileNameWithoutExtension(f2[MaxNum]); char[] c0 = { '-' }; switch (MaxNum) { case 0: if (max == false) label5.Text = museic; else label45.Text = museic; string[] ss0 = label45.Text.Split(c0); label48.Text = ss0[0]; //时长 //this.label59.Text = this.axWindowsMediaPlayer1.currentMedia.durationString; break; case 1: if (max == false) label6.Text = museic; else label44.Text = museic; string[] ss1 = label44.Text.Split(c0); label49.Text = ss1[0]; //label59.Text break; case 2: if (max == false) label7.Text = museic; else label43.Text = museic; string[] ss2 = label43.Text.Split(c0); label50.Text = ss2[0]; break; case 3: if (max == false) label8.Text = museic; else label42.Text = museic; string[] ss3 = label42.Text.Split(c0); label51.Text = ss3[0]; break; case 4: if (max == false) label9.Text = museic; else label41.Text = museic; string[] ss4 = label41.Text.Split(c0); label52.Text = ss4[0]; break; case 5: if (max == false) label75.Text = museic; else label40.Text = museic; string[] ss5 = label40.Text.Split(c0); label53.Text = ss5[0]; break; case 6: if (max == false) label76.Text = museic; else label39.Text = museic; string[] ss6 = label39.Text.Split(c0); label54.Text = ss6[0]; break; case 7: if (max == false) label77.Text = museic; else label38.Text = museic; string[] ss7 = label38.Text.Split(c0); label55.Text = ss7[0]; break; case 8: if (max == false) label78.Text = museic; else label37.Text = museic; string[] ss8 = label37.Text.Split(c0); label56.Text = ss8[0]; break; } MaxNum = MaxNum 1; if (MaxNum > files.Length - 1) break; } } //*********************************************************** //************************调整播放模式*********************** //*********************************************************** private void pictureBox26_Click(object sender, EventArgs e) { moshi = moshi 1; if (moshi == 2) { pictureBox26.Image = Properties.Resources.danqu2; } if (moshi == 3) { pictureBox26.Image = Properties.Resources.suiji2; } if (moshi > 3) { moshi = 1; pictureBox26.Image = Properties.Resources.shunxu2; } } //精简模式 private void pictureBox25_Click(object sender, EventArgs e) { moshi = moshi 1; if (moshi == 2) { pictureBox25.Image = Properties.Resources.danqu2; } if (moshi == 3) { pictureBox25.Image = Properties.Resources.suiji2; } if (moshi > 3) { moshi = 1; pictureBox25.Image = Properties.Resources.shunxu2; } } //判断是否点击 bool dianji20 = false; bool dianji21 = false; bool dianji19 = false; bool dianji18 = false; bool dianji22 = false; bool dianji24 = false; //点击判断 void pd() { if (dianji18 == true || dianji19 == true || dianji20 == true || dianji21 == true || dianji22 == true || dianji24 == true) { dianji18 = false; dianji19 = false; dianji20 = false; dianji21 = false; dianji22 = false; dianji24 = false; label18.Image = null; label19.Image = null; label20.Image = null; label21.Image = null; label22.Image = null; label24.Image = null; } } private void label20_Click(object sender, EventArgs e) { pd(); label20.Image = Properties.Resources._1; dianji20 = true; } private void label21_Click(object sender, EventArgs e) { pd(); label21.Image = Properties.Resources._1; dianji21 = true; } bool ben = false; private void label19_Click(object sender, EventArgs e) { string wenjianBen = @"c:\yinyue\lianjie"; if (!Directory.Exists(wenjianBen)) { MessageBox.Show("无本地信息,请先添加歌曲!"); return; } if (ben == true) return; ye1 = 1; label58.Text = ye1.ToString(); pd(); bendi(); //导入本地音乐 panel16.Visible = true; label19.Image = Properties.Resources._1; dianji19 = true; xi = false; ben = true; } private void label18_Click(object sender, EventArgs e) { pd(); label18.Image = Properties.Resources._1; dianji18 = true; } private void label22_Click(object sender, EventArgs e) { pd(); label22.Image = Properties.Resources._1; dianji22 = true; } //**************************** //喜欢的歌曲 void xh() { string a = @"c:\yinyue\lianjie\like"; if (!Directory.Exists(a)) { return; } panel16.Visible = true; ye1 = 1; label58.Text = ye1.ToString(); ben = false; xi = true; pd(); label24.Image = Properties.Resources._1; dianji24 = true; //打开收藏列表 label45.Text = ""; label44.Text = ""; label43.Text = ""; label42.Text = ""; label41.Text = ""; label40.Text = ""; label39.Text = ""; label38.Text = ""; label37.Text = ""; char[] c0 = { '-' }; MaxNum = 0; string[] files = System.IO.Directory.GetFiles(gequ "\\like"); zongshu = files.Length; ye = files.Length / 9;//几首歌曲 if (files.Length % 9 != 0) ye = ye 1; label70.Text = ye.ToString(); label100.Text = ye.ToString(); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 while (true) { if (zongshu == 0) break; museic = Path.GetFileNameWithoutExtension(f2[MaxNum]); switch (MaxNum) { case 0: if (max == false) label5.Text = museic; else label45.Text = museic; string[] ss0 = label45.Text.Split(c0); label48.Text = ss0[0]; break; case 1: if (max == false) label6.Text = museic; else label44.Text = museic; string[] ss1 = label44.Text.Split(c0); label49.Text = ss1[0]; break; case 2: if (max == false) label7.Text = museic; else label43.Text = museic; string[] ss2 = label43.Text.Split(c0); label50.Text = ss2[0]; break; case 3: if (max == false) label8.Text = museic; else label42.Text = museic; string[] ss3 = label42.Text.Split(c0); label51.Text = ss3[0]; break; case 4: if (max == false) label9.Text = museic; else label41.Text = museic; string[] ss4 = label41.Text.Split(c0); label52.Text = ss4[0]; break; case 5: if (max == false) label75.Text = museic; else label40.Text = museic; string[] ss5 = label40.Text.Split(c0); label53.Text = ss5[0]; break; case 6: if (max == false) label76.Text = museic; else label39.Text = museic; string[] ss6 = label39.Text.Split(c0); label54.Text = ss6[0]; break; case 7: if (max == false) label77.Text = museic; else label38.Text = museic; string[] ss7 = label38.Text.Split(c0); label55.Text = ss7[0]; break; case 8: if (max == false) label78.Text = museic; else label37.Text = museic; string[] ss8 = label37.Text.Split(c0); label56.Text = ss8[0]; break; } MaxNum = MaxNum 1; if (MaxNum > files.Length - 1) break; } } bool xi = false; private void label24_Click(object sender, EventArgs e) { if (xi == true) return; label48.Text = ""; label49.Text = ""; label50.Text = ""; label51.Text = ""; label52.Text = ""; label53.Text = ""; label54.Text = ""; label55.Text = ""; label56.Text = ""; geQuDianJ(); xh(); } private void panel17_MouseEnter(object sender, EventArgs e) { panel17.BackgroundImage = Properties.Resources.s; } private void panel17_MouseLeave(object sender, EventArgs e) { panel17.BackgroundImage = null; } private void label37_MouseEnter(object sender, EventArgs e) { label37.Image = Properties.Resources.s; } private void label37_MouseLeave(object sender, EventArgs e) { label37.Image = null; } private void pictureBox26_MouseHover(object sender, EventArgs e) { if (moshi == 1) toolTip1.SetToolTip(pictureBox26, "列表循环"); if (moshi == 2) toolTip1.SetToolTip(pictureBox26, "单曲"); if (moshi == 3) toolTip1.SetToolTip(pictureBox26, "随机播放"); } private void pictureBox25_MouseHover(object sender, EventArgs e) { if (moshi == 1) toolTip1.SetToolTip(pictureBox25, "列表循环"); if (moshi == 2) toolTip1.SetToolTip(pictureBox25, "单曲"); if (moshi == 3) toolTip1.SetToolTip(pictureBox25, "随机播放"); } private void label45_MouseEnter(object sender, EventArgs e) { jiechu(sender); } private void label45_MouseLeave(object sender, EventArgs e) { if(la45==false) likai(sender); else label45.Image = Properties.Resources.s; } private void label44_MouseEnter(object sender, EventArgs e) { jiechu(sender); } private void label44_MouseLeave(object sender, EventArgs e) { if (la44 == false) likai(sender); else label44.Image = Properties.Resources.s; } private void label43_MouseEnter(object sender, EventArgs e) { jiechu(sender); } private void label43_MouseLeave(object sender, EventArgs e) { if (la43 == false) likai(sender); else label43.Image = Properties.Resources.s; } private void label42_MouseEnter(object sender, EventArgs e) { jiechu(sender); } private void label42_MouseLeave(object sender, EventArgs e) { if (la42 == false) likai(sender); else label42.Image = Properties.Resources.s; } private void label41_MouseEnter(object sender, EventArgs e) { jiechu(sender); } private void label41_MouseLeave(object sender, EventArgs e) { if (la41 == false) likai(sender); else label41.Image = Properties.Resources.s; } private void label40_MouseEnter(object sender, EventArgs e) { jiechu(sender); } private void label40_MouseLeave(object sender, EventArgs e) { if (la40 == false) likai(sender); else label40.Image = Properties.Resources.s; } private void label39_MouseEnter(object sender, EventArgs e) { jiechu(sender); } private void label39_MouseLeave(object sender, EventArgs e) { if (la39 == false) likai(sender); else label39.Image = Properties.Resources.s; } private void label38_MouseEnter(object sender, EventArgs e) { jiechu(sender); } private void label38_MouseLeave(object sender, EventArgs e) { if (la38 == false) likai(sender); else label38.Image = Properties.Resources.s; } private void label37_MouseEnter_1(object sender, EventArgs e) { jiechu(sender); } private void label37_MouseLeave_1(object sender, EventArgs e) { if (la37 == false) likai(sender); else label37.Image = Properties.Resources.s; } bool la45 = false; bool la44 = false; bool la43 = false; bool la42 = false; bool la41 = false; bool la40 = false; bool la39 = false; bool la38 = false; bool la37 = false; void geQuDianJ() { if (la45 == true || la44 == true || la43 == true || la42 == true || la41 == true || la40 == true || la39 == true || la38 == true || la37 == true) { la37 = false; label37.Image = null; la38 = false; label38.Image = null; la39 = false; label39.Image = null; la40 = false; label40.Image = null; la41 = false; label41.Image = null; la42 = false; label42.Image = null; la43 = false; label43.Image = null; la44 = false; label44.Image = null; la45 = false; label45.Image = null; } } private void label45_Click(object sender, EventArgs e) { if (label45.Text == "") return; geQuDianJ(); la45 = true; label45.Image = Properties.Resources.s; label14.Text = label45.Text; label31.Text = label45.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label45.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label44_Click(object sender, EventArgs e) { if (label44.Text == "") return; geQuDianJ(); la44 = true; label44.Image = Properties.Resources.s; label14.Text = label44.Text; label31.Text = label44.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1) 1; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[1]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label44.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label43_Click(object sender, EventArgs e) { if (label43.Text == "") return; geQuDianJ(); la43 = true; label43.Image = Properties.Resources.s; label14.Text = label43.Text; label31.Text = label43.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1) 2; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[2]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label43.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label42_Click(object sender, EventArgs e) { if (label42.Text == "") return; geQuDianJ(); la42 = true; label42.Image = Properties.Resources.s; label14.Text = label42.Text; label31.Text = label42.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1) 3; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[3]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label42.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label41_Click(object sender, EventArgs e) { if (label41.Text == "") return; geQuDianJ(); la41 = true; label41.Image = Properties.Resources.s; label14.Text = label41.Text; label31.Text = label41.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1) 4; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[4]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label41.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label40_Click(object sender, EventArgs e) { if (label40.Text == "") return; geQuDianJ(); la40 = true; label40.Image = Properties.Resources.s; label14.Text = label40.Text; label31.Text = label40.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1) 5; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[5]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label40.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label39_Click(object sender, EventArgs e) { if (label39.Text == "") return; geQuDianJ(); la39 = true; label39.Image = Properties.Resources.s; label14.Text = label39.Text; label31.Text = label39.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1) 6; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[6]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label39.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label38_Click(object sender, EventArgs e) { if (label38.Text == "") return; geQuDianJ(); la38 = true; label38.Image = Properties.Resources.s; label14.Text = label38.Text; label31.Text = label38.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1) 7; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[7]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label38.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label37_Click(object sender, EventArgs e) { if (label37.Text == "") return; geQuDianJ(); la37 = true; label37.Image = Properties.Resources.s; label14.Text = label37.Text; label31.Text = label37.Text; string museic; int y = int.Parse(label58.Text); MaxNum = 9 * (y - 1) 8; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[8]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label37.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } //************************************************** //***********************透明度********************* //************************************************** int tm;//透明度 public void touming(int op) { this.Opacity = (double)op / 200; } private void panel18_MouseDown(object sender, MouseEventArgs e) { panel19.Size = new Size(e.Location.X, 4); tm = e.Location.X; touming(tm); } private void panel19_MouseDown(object sender, MouseEventArgs e) { panel19.Size = new Size(e.Location.X, 4); tm = e.Location.X; touming(tm); } int ye1 = 1; private void label47_Click(object sender, EventArgs e) { if (ye > 1) { if (ye1 < ye) { ye1 = ye1 1; label58.Text = ye1.ToString(); label45.Text = ""; label44.Text = ""; label43.Text = ""; label42.Text = ""; label41.Text = ""; label40.Text = ""; label39.Text = ""; label38.Text = ""; label37.Text = ""; label48.Text = ""; label49.Text = ""; label50.Text = ""; label51.Text = ""; label52.Text = ""; label53.Text = ""; label54.Text = ""; label55.Text = ""; label56.Text = ""; geQuDianJ(); string[] files = System.IO.Directory.GetFiles(gequ); string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 int ci = 0; int xh = 0; //歌曲序号 int y = int.Parse(label58.Text); xh = 9 * (y-1); char[] c0 = { '-' }; while (true) { //int y = int.Parse(label58.Text); //if (xh 9*y >= files.Length-1) // break; museic = Path.GetFileNameWithoutExtension(f2[xh]); switch (ci) { case 0: label45.Text = museic; string[] ss0 = label45.Text.Split(c0); label48.Text = ss0[0]; break; case 1: label44.Text = museic; string[] ss1 = label44.Text.Split(c0); label49.Text = ss1[0]; break; case 2: label43.Text = museic; string[] ss2 = label43.Text.Split(c0); label50.Text = ss2[0]; break; case 3: label42.Text = museic; string[] ss3 = label42.Text.Split(c0); label51.Text = ss3[0]; break; case 4: label41.Text = museic; string[] ss4 = label41.Text.Split(c0); label52.Text = ss4[0]; break; case 5: label40.Text = museic; string[] ss5 = label40.Text.Split(c0); label53.Text = ss5[0]; break; case 6: label39.Text = museic; string[] ss6 = label39.Text.Split(c0); label54.Text = ss6[0]; break; case 7: label38.Text = museic; string[] ss7 = label38.Text.Split(c0); label55.Text = ss7[0]; break; case 8: label37.Text = museic; string[] ss8 = label37.Text.Split(c0); label56.Text = ss8[0]; break; } xh=xh 1; ci = ci 1; //ci = ci 1; //if (ci == 9) // break; if (xh > files.Length - 1) break; } } } } private void label46_Click(object sender, EventArgs e) { if (ye1 > 1) { ye1 = ye1 - 1; label58.Text = ye1.ToString(); label45.Text = ""; label44.Text = ""; label43.Text = ""; label42.Text = ""; label41.Text = ""; label40.Text = ""; label39.Text = ""; label38.Text = ""; label37.Text = ""; label48.Text = ""; label49.Text = ""; label50.Text = ""; label51.Text = ""; label52.Text = ""; label53.Text = ""; label54.Text = ""; label55.Text = ""; label56.Text = ""; geQuDianJ(); string[] files = System.IO.Directory.GetFiles(gequ); string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 int ci = 0; int xh = 0; //歌曲序号 int y = int.Parse(label58.Text); xh = 9 * ((y 1) - 1) - 9; while (true) { //int y = int.Parse(label58.Text); //if (xh 9*y >= files.Length-1) // break; char[] c0 = { '-' }; museic = Path.GetFileNameWithoutExtension(f2[xh]); switch (ci) { case 0: label45.Text = museic; string[] ss0 = label45.Text.Split(c0); label48.Text = ss0[0]; break; case 1: label44.Text = museic; string[] ss1 = label44.Text.Split(c0); label49.Text = ss1[0]; break; case 2: label43.Text = museic; string[] ss2 = label43.Text.Split(c0); label50.Text = ss2[0]; break; case 3: label42.Text = museic; string[] ss3 = label42.Text.Split(c0); label51.Text = ss3[0]; break; case 4: label41.Text = museic; string[] ss4 = label41.Text.Split(c0); label52.Text = ss4[0]; break; case 5: label40.Text = museic; string[] ss5 = label40.Text.Split(c0); label53.Text = ss5[0]; break; case 6: label39.Text = museic; string[] ss6 = label39.Text.Split(c0); label54.Text = ss6[0]; break; case 7: label38.Text = museic; string[] ss7 = label38.Text.Split(c0); label55.Text = ss7[0]; break; case 8: label37.Text = museic; string[] ss8 = label37.Text.Split(c0); label56.Text = ss8[0]; break; } xh = xh 1; ci = ci 1; //ci = ci 1; //if (ci == 9) // break; if (xh > files.Length - 1) break; } } } private void pictureBox12_Click(object sender, EventArgs e) { if (ye > 1) { if (ye1 < ye) { ye1 = ye1 1; label99.Text = ye1.ToString(); label5.Text = ""; label6.Text = ""; label7.Text = ""; label8.Text = ""; label9.Text = ""; label75.Text = ""; label76.Text = ""; label77.Text = ""; label78.Text = ""; string[] files = System.IO.Directory.GetFiles(gequ); string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 int ci = 0; int xh = 0; //歌曲序号 int y = int.Parse(label99.Text); xh = 9 * (y - 1); while (true) { //int y = int.Parse(label58.Text); //if (xh 9*y >= files.Length-1) // break; museic = Path.GetFileNameWithoutExtension(f2[xh]); switch (ci) { case 0: label5.Text = museic; break; case 1: label6.Text = museic; break; case 2: label7.Text = museic; break; case 3: label8.Text = museic; break; case 4: label9.Text = museic; break; case 5: label75.Text = museic; break; case 6: label76.Text = museic; break; case 7: label77.Text = museic; break; case 8: label78.Text = museic; break; } xh = xh 1; ci = ci 1; //ci = ci 1; //if (ci == 9) // break; if (xh > files.Length - 1) break; } } } } private void pictureBox13_Click(object sender, EventArgs e) { if (ye1 > 1) { ye1 = ye1 - 1; label99.Text = ye1.ToString(); label5.Text = ""; label6.Text = ""; label7.Text = ""; label8.Text = ""; label9.Text = ""; label75.Text = ""; label76.Text = ""; label77.Text = ""; label78.Text = ""; string[] files = System.IO.Directory.GetFiles(gequ); string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 int ci = 0; int xh = 0; //歌曲序号 int y = int.Parse(label99.Text); xh = 9 * ((y 1) - 1) - 9; while (true) { //int y = int.Parse(label58.Text); //if (xh 9*y >= files.Length-1) // break; museic = Path.GetFileNameWithoutExtension(f2[xh]); switch (ci) { case 0: label5.Text = museic; break; case 1: label6.Text = museic; break; case 2: label7.Text = museic; break; case 3: label8.Text = museic; break; case 4: label9.Text = museic; break; case 5: label75.Text = museic; break; case 6: label76.Text = museic; break; case 7: label77.Text = museic; break; case 8: label78.Text = museic; break; } xh = xh 1; ci = ci 1; //ci = ci 1; //if (ci == 9) // break; if (xh > files.Length - 1) break; } } } int aa = 269; char c = ']'; int bb = 84; string gc = ""; string gcsj = ""; string gcsjl = ""; bool you = true; int chang = 0; private void timer2_Tick(object sender, EventArgs e) { label31.Location = new Point(aa, bb); if (you == true) aa = aa 2; if (you == false) aa = aa - 2; if (aa > 300) you = false; if (aa < 269) you = true; if (label31.Text == "陈奕迅 - 单车.mp3") { StreamReader sr = new StreamReader("lrc\\aa.Lrc"); while (true) { gcsjl = label4.Text; gc = sr.ReadLine(); if (gc == null) { sr.Close(); break; } chang = gc.Length - 10; string[] a = gc.Split(c); gcsj = a[0].Substring(1, 5); //label18.Text = gcsj; //label22.Text = gcsjl; if (gcsj == gcsjl) { gc = gc.Substring(10, chang); label79.Text = gc; sr.Close(); break; } } //if(ks==false) // gc= sr.ReadLine(); //else //{ //} // if (gc == null) // return; // int chang = gc.Length - 10; // if (gc.Substring(0, 4) == "[00:" && ks == false) // { // string[] a = gc.Split(c); // gcsj=a[0].Substring(1, 5); // gc = gc.Substring(10, chang); // ks = true; // } // else // if (ks == true) // { // gc = gc.Substring(10, chang); // } } } private void pictureBox3_Click(object sender, EventArgs e) { #region 下一曲 if (ben == false) return; string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 MaxNum = MaxNum 1; if (MaxNum 1 >= zongshu 1) { MaxNum = 1; museic = Path.GetFileNameWithoutExtension(f2[0]); } else museic = Path.GetFileNameWithoutExtension(f2[MaxNum]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" museic ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; label31.Text = museic; label14.Text = museic; //timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } #endregion } private void pictureBox1_Click(object sender, EventArgs e) { #region 上一曲 if (ben == false) return; string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 MaxNum = MaxNum - 1; if (MaxNum - 1 <0) { MaxNum = zongshu; museic = Path.GetFileNameWithoutExtension(f2[0]); } else museic = Path.GetFileNameWithoutExtension(f2[MaxNum]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" museic ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; label31.Text = museic; label14.Text = museic; //timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } #endregion } private void pictureBox17_Click(object sender, EventArgs e) { #region 下一曲 string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 MaxNum = MaxNum 1; if (MaxNum 1 >= zongshu 1) { MaxNum = 1; museic = Path.GetFileNameWithoutExtension(f2[0]); } else museic = Path.GetFileNameWithoutExtension(f2[MaxNum]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" museic ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; label31.Text = museic; label14.Text = museic; label74.Text = museic; //timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } #endregion } private void pictureBox18_Click(object sender, EventArgs e) { #region 上一曲 string museic; string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 MaxNum = MaxNum - 1; if (MaxNum - 1 < 0) { MaxNum = zongshu; museic = Path.GetFileNameWithoutExtension(f2[0]); } else museic = Path.GetFileNameWithoutExtension(f2[MaxNum]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" museic ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; label31.Text = museic; label14.Text = museic; label74.Text = museic; //timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } #endregion } private void label5_Click(object sender, EventArgs e) { if (label15.Text == "") return; label14.Text = label5.Text; label31.Text = label5.Text; label74.Text = label5.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label5.Text ".txt"); string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label6_Click(object sender, EventArgs e) { if (label6.Text == "") return; label14.Text = label6.Text; label31.Text = label6.Text; label74.Text = label6.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label6.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label7_Click(object sender, EventArgs e) { if (label7.Text == "") return; label14.Text = label7.Text; label31.Text = label7.Text; label74.Text = label7.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label7.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label8_Click(object sender, EventArgs e) { if (label8.Text == "") return; label14.Text = label8.Text; label31.Text = label8.Text; label74.Text = label8.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label8.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label9_Click(object sender, EventArgs e) { if (label9.Text == "") return; label14.Text = label9.Text; label31.Text = label9.Text; label74.Text = label9.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label9.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label75_Click(object sender, EventArgs e) { if (label75.Text == "") return; label14.Text = label75.Text; label31.Text = label75.Text; label74.Text = label75.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label75.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label76_Click(object sender, EventArgs e) { if (label76.Text == "") return; label14.Text = label76.Text; label31.Text = label76.Text; label74.Text = label76.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label76.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label77_Click(object sender, EventArgs e) { if (label77.Text == "") return; label14.Text = label77.Text; label31.Text = label77.Text; label74.Text = label77.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label77.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } private void label78_Click(object sender, EventArgs e) { if (label78.Text == "") return; label14.Text = label78.Text; label31.Text = label78.Text; label74.Text = label78.Text; string museic; int y = int.Parse(label99.Text); MaxNum = 9 * (y - 1); string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 museic = Path.GetFileNameWithoutExtension(f2[0]); try { //帐号 using (StreamReader sr = new StreamReader(@"c:\yinyue\lianjie\" label78.Text ".txt")) { string bf; //读取所有的内容 while ((bf = sr.ReadLine()) != null) { //Console.WriteLine(line); break; } axWindowsMediaPlayer1.URL = bf; timer1.Enabled = true; } } catch (Exception ex) { //异常 MessageBox.Show(ex.Message); } } //*********************************************** //********************我喜欢的歌曲*************** //*********************************************** string[] like = new string[1]; int likeNum = 0; private void pictureBox4_Click(object sender, EventArgs e) { string[] f2 = Directory.GetFiles(gequ); //获取该文件夹面所文名 like[likeNum] = Path.GetFileNameWithoutExtension(f2[MaxNum]); string wenjian = @"c:\yinyue\lianjie\like"; if (!Directory.Exists(wenjian)) { Directory.CreateDirectory(wenjian); } StreamWriter sw = new StreamWriter("c:\\yinyue\\lianjie\\like\\" like[likeNum] ".txt"); string lk = like[likeNum]; sw.Write(lk); sw.Close(); } private void pictureBox7_Click(object sender, EventArgs e) { if (pifu == true) { panel15.Visible = false; pifu = false; } if (panel20.Visible == false) panel20.Visible = true; else panel20.Visible = false; } private void pictureBox28_Click(object sender, EventArgs e) { this.BackgroundImage = null; this.BackColor = pictureBox28.BackColor; } private void pictureBox29_Click(object sender, EventArgs e) { this.BackgroundImage = null; this.BackColor = pictureBox29.BackColor; } private void pictureBox30_Click(object sender, EventArgs e) { this.BackgroundImage = null; this.BackColor = pictureBox30.BackColor; } private void pictureBox31_Click(object sender, EventArgs e) { this.BackgroundImage = null; //this.BackColor = Color.Lime; this.BackColor = pictureBox31.BackColor; } private void pictureBox32_Click(object sender, EventArgs e) { this.BackgroundImage = null; this.BackColor = pictureBox32.BackColor; } private void pictureBox33_Click(object sender, EventArgs e) { panel8.BackColor = pictureBox33.BackColor; } private void pictureBox34_Click(object sender, EventArgs e) { panel8.BackColor = pictureBox34.BackColor; } private void pictureBox35_Click(object sender, EventArgs e) { panel8.BackColor = pictureBox35.BackColor; } private void pictureBox36_Click(object sender, EventArgs e) { panel8.BackColor = pictureBox36.BackColor; } private void pictureBox37_Click(object sender, EventArgs e) { panel8.BackColor = pictureBox37.BackColor; } private void panel3_Paint(object sender, PaintEventArgs e) { } }}
评论